//
//  MainHeaderScrollView.m
//  MusicPlayer
//
//  Created by lanou on 15/12/2.
//  Copyright © 2015年 Morrrah. All rights reserved.
//

#import "MainHeaderScrollView.h"

@implementation MainHeaderScrollView

- (instancetype)initWithFrame:(CGRect)frame target:(id)target action:(SEL)action imageArray:(NSArray *)imageArray timer:(NSTimeInterval )timer selector:(SEL)selector
{
    if (self = [super initWithFrame:frame]) {
        NSMutableArray *insterImageArray = [NSMutableArray arrayWithArray:imageArray];
        [insterImageArray insertObject:imageArray.lastObject atIndex:0];
        self.contentSize = CGSizeMake(insterImageArray.count * ScreenWidth, 0);
        self.bounces = NO;
        self.delegate = target;
        self.pagingEnabled = YES;
        self.contentOffset = CGPointMake(ScreenWidth, 0);
        self.showsHorizontalScrollIndicator = NO;
        for (int i = 0; i < insterImageArray.count; i ++) {
            TapImageView *tapImageView = [[TapImageView alloc]initWithFrame:CGRectMake(ScreenWidth * i, 0, ScreenWidth, frame.size.height) target:target action:action];
            [tapImageView sd_setImageWithURL:insterImageArray[i]];
            [self addSubview:tapImageView];
        }
        [NSTimer scheduledTimerWithTimeInterval:timer target:target selector:selector userInfo:nil repeats:YES];
    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
